﻿<%@ Page Language="C#" MasterPageFile="~/Home/ad/admin.master" AutoEventWireup="true" CodeFile="ad_sp_daugia.aspx.cs" Inherits="Home_ad_ad_sp_daugia" Title="Welcome to IT" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="Lbmasse" runat="server" Text=""></asp:Label><br />
    &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<asp:FileUpload ID="FileUpload_upload" runat="server" /><br />
    <br />
    <asp:Button ID="Add" runat="server" Text="Thêm mới" OnClick="Add_Click" /><br />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:db_connection %>"
        DeleteCommand="DELETE FROM [DM001] WHERE [isbn] = @isbn" InsertCommand="INSERT INTO [DM001] ([DienGiai]) VALUES (@DienGiai)"
        SelectCommand="SELECT * FROM [DM001] ORDER BY [DienGiai]" UpdateCommand="UPDATE [DM001] SET [DienGiai] = @DienGiai WHERE [isbn] = @isbn">
        <DeleteParameters>
            <asp:Parameter Name="isbn" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="DienGiai" Type="String" />
            <asp:Parameter Name="isbn" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="DienGiai" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <br />
    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
        DataTextField="DienGiai" DataValueField="isbn">
    </asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:db_connection %>"
        SelectCommand="SELECT * FROM [DM002] WHERE ([MaDM001] = @MaDM001)">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList1" Name="MaDM001" PropertyName="SelectedValue"
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"
        DataTextField="DienGiai" DataValueField="MaDM001">
    </asp:DropDownList><br />
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:db_connection %>"
        DeleteCommand="DELETE FROM [SP001] WHERE [isbn] = @isbn" InsertCommand="INSERT INTO [SP001] ([TenSP], [TenHinh], [DienGiai]) VALUES (@TenSP, @TenHinh, @DienGiai)"
        SelectCommand="SELECT [isbn], [TenSP], [TenHinh], [DienGiai] FROM [SP001] WHERE ([MaDM002] = @MaDM002) ORDER BY [DienGiai]"
        UpdateCommand="UPDATE [SP001] SET [TenSP] = @TenSP, [TenHinh] = @TenHinh, [DienGiai] = @DienGiai WHERE [isbn] = @isbn">
        <DeleteParameters>
            <asp:Parameter Name="isbn" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="TenSP" Type="String" />
            <asp:Parameter Name="TenHinh" Type="String" />
            <asp:Parameter Name="DienGiai" Type="String" />
            <asp:Parameter Name="isbn" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList2" Name="MaDM002" PropertyName="SelectedValue"
                Type="Int32" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="TenSP" Type="String" />
            <asp:Parameter Name="TenHinh" Type="String" />
            <asp:Parameter Name="DienGiai" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:db_connection %>"
        SelectCommand="SELECT [isbn], [TenSP], [TenHinh], [DienGiai] FROM [SP001]"></asp:SqlDataSource>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" DataKeyNames="isbn" DataSourceID="SqlDataSource4"
        Width="459px">
        <Columns>
            <asp:BoundField DataField="isbn" HeaderText="isbn" InsertVisible="False" ReadOnly="True"
                SortExpression="isbn" />
            <asp:BoundField DataField="TenSP" HeaderText="TenSP" SortExpression="TenSP" />
            <asp:BoundField DataField="TenHinh" HeaderText="TenHinh" SortExpression="TenHinh" />
            <asp:BoundField DataField="DienGiai" HeaderText="DienGiai" SortExpression="DienGiai" />
            <asp:CommandField ShowEditButton="True" />
        </Columns>
    </asp:GridView>
    <br />

</asp:Content>

